package middlewares

import (
	"library-system/utils"

	"github.com/gin-gonic/gin"
)

func AdminAuth() gin.HandlerFunc {
	return func(c *gin.Context) {
		claims := c.MustGet("claims").(*utils.Claims)
		if claims.Role != "admin" {
			utils.Error(c, utils.ForbiddenCode, "需要管理员权限")
			c.Abort()
			return
		}
		c.Next()
	}
}
